<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@ page contentType="text/html; charset=UTF-8" language="java"
	import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/page/base.jsp"%>
<%@ taglib prefix="d" uri="/doone-comm-ui-tags"%>

<html>
	<head>
		<title>企业微博信息</title>
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->



		</style>
		<link type="text/css" href="<%=path%>/manage/css/layout.css"
			rel="stylesheet" />
		<link rel="stylesheet" type="text/css"
			href="<%=path%>/manage/css/Tooltip.css" />
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery-1.4.4.min.js"></script>

		<script type="text/javascript"
			src="<%=path%>/manage/js/easyTooltip.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery-ui-1.8.11.custom.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.wysiwyg.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/hoverIntent.js"></script>
		<script type="text/javascript" src="<%=path%>/manage/js/superfish.js"></script>
		<script type="text/javascript" src="<%=path%>/manage/js/custom.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/My97DatePicker/WdatePicker.js"></script>
		<%-- 验证js Start --%>
		<script type="text/javascript" src="<%=path%>/manage/js/Tooltip.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.methods.min.js"></script>
		<script type="text/javascript"
			src="<%=path%>/manage/js/jquery.validate.defaults.js"></script>



		<script type="text/javascript">
	//用于判断还是更新 tru更新 false增加
	var falg = true;
	//企业微博编辑	
	function editMiscroBo(intWeiboId) {
		//$("#varShopName").removeErrorMessageAndClass();	
		falg = true;
		$.ajax({
			url : root + '/app/getEditMiscroBo.action',
			method : 'post',
			dataType : 'json',
			data : {
				'intWeiboId' : intWeiboId
			},
			success : function(data) {				
				//给form的文本赋值
				//应用名称		
				$("#varAppName").attr("value", data.varAppName);
				//微博名称
				$("#varWeiboName").attr("value", data.varWeiboName);
				//微博类型
				$("#intWeiboType").attr("value", data.intWeiboType);
				//APPKEY
				$("#appkey").attr("value", data.appkey);
				//APPSECRETKEY
				$("#appsecretkey").attr("value", data.appsecretkey);
				//CALLBACKURL
				$("#callbackurl").attr("value", data.callbackurl);

				$("#intWeiboId").attr("value", data.intWeiboId);
				//打开dialog
				$("#openMicroBoDialog").dialog("open");
			},
			error : function(err) {
				if (err.responseText != '')
					alert(err.responseText);
				else
					alert("请求失败！");
			}
		});
	}
	//企业微博增加
	function addEnterShop() {
		falg = false;
		//清空form的值
		//应用名称		
		$("#varAppName").attr("value", "");
		//微博名称
		$("#varWeiboName").attr("value", "");
		//微博类型
		$("#intWeiboType").attr("value", "");
		//APPKEY
		$("#appkey").attr("value", "");
		//APPSECRETKEY
		$("#appsecretkey").attr("value", "");
		//CALLBACKURL
		$("#callbackurl").attr("value", "");

		$("#intWeiboId").attr("value", "");
		//打开dialog
		$("#openMicroBoDialog").dialog("open");
	}
	//企业微博信息删除
	function delMiscroBo(intWeiboId) {
		if (confirm("慎重考虑是否确定删除该记录?删除后无法查看该条记录！！！")) {
			$.ajax({
				url : root + '/app/doDelMiscroBo.action',
				method : 'post',
				data : {
					'intWeiboId' : intWeiboId
				},
				success : function(data) {
					window.location.href = root
							+ '/app/getMicroBoInfo.action';
				},
				error : function(err) {
					if (err.responseText != '')
						alert(err.responseText);
					else
						alert("请求失败！");
				}
			});
		}
	}
	$(document)
			.ready(
					function() {
						//验证						
						var editMiscroBoForm = $("#editMiscroBoForm").validate(
								{
									rules : {
										"enterMiscroBoDto.varWeiboName" : {
											required : true
										}

									},
									messages : {
										"enterMiscroBoDto.varWeiboName" : {
											required : "微博名称必填"
										}
									}
								});

						//加载dialog
						$("#openMicroBoDialog")
								.dialog(
										{
											autoOpen : false,
											width : 850,
											height : 350,
											modal : true,
											title : '企业微博信息编辑',
											buttons : {
												"保存" : function() {

													//判断验证
													//if (editMiscroBoForm) {
														//alert("验证没通过，数据无法保存");
													//} else {
														//判断更新还是增加 默认
														if (falg) {
															$(
																	"#editMiscroBoForm")
																	.submit();
														} else {
															$(
																	"#editMiscroBoForm")
																	.attr(
																			"action",
																			root
																					+ '/app/doAddMiscroBo.action');
															$(
																	"#editMiscroBoForm")
																	.submit();
														}
														$(this).dialog("close");
													//}
													//$("#searchBtn").click();
												},
												"取消" : function() {
													$(this).dialog("close");
													$("#editMiscroBoForm")[0]
															.reset();
												}
											},
											close : function() {
												$("#editMiscroBoForm")[0]
														.reset();
											}
										});

					});



</script>
	<body>
		<div>
			<p class="sitemap">
				当前位置：企业微博管理> 企业微博信息管理
			</p>
			<h1>
				企业微博管理
			</h1>
			<div>
				<!-- Tabs -->
				<div id="tabs">
					<ul>
						<li>
							<a href="#tabs-1">微博列表</a>
						</li>

					</ul>
					<div style="align: right">
						<input type="submit" value="新增微博" onClick="addEnterShop()">
					</div>
					<table class="fullwidth" cellpadding="0" cellspacing="0" border="0">
						<thead>

							<tr>
								<td>
									应用名称
								</td>
								<td>
									微博名称
								</td>
								<td>
									微博类型
								</td>
								<td>
									APPKEY
								</td>
								<td>
									APPSECRETKEY
								</td>
								<td>
									CALLBACKURL
								</td>
								<td>
									操作
								</td>
							</tr>
						</thead>
						<tbody>
							<s:iterator value="microBoList">
								<tr class="odd">
									<td>
										<s:property value="varAppName" />
									</td>
									<td>
										<s:property value="varWeiboName" />
									</td>
									<td>
										<s:property value="weiBoTypeName" />
									</td>
									<td>
										<s:property value="appkey" />
									</td>
									<td>
										<s:property value="appsecretkey" />
									</td>
									<td>
										<s:property value="callbackurl" />
									</td>

									<td>
										<a
											href="javascript:editMiscroBo('<s:property value="intWeiboId" />')">编辑</a>
										<a
											href="javascript:delMiscroBo('<s:property value="intWeiboId" />')">删除</a>
									</td>

								</tr>
							</s:iterator>
						</tbody>
					</table>

				</div>
				<!-- 分页标签开始 -->
				<div align="right" style="float: right;">
					<d:page id="page" template="details" skin="gray">
					</d:page>
				</div>
				<!-- 分页标签结束 -->
			</div>
		</div>

		<!-- 编辑页使用的弹出层 -->
		<div id="openMicroBoDialog" style="display: none;">
			<form action="<%=path%>/app/doEditMiscroBo.action"
				method="post" id="editMiscroBoForm">
				<s:hidden name="enterMiscroBoDto.intWeiboId" id="intWeiboId"></s:hidden>
				<table class="fullwidth" cellpadding="0" cellspacing="0" border="1">
					<tr>
						<td>
							应用名称
						</td>
						<td>
							<s:textfield name="enterMiscroBoDto.varAppName" id="varAppName"
								readonly="true" cssClass="textbox_border"></s:textfield>
						</td>
					</tr>
					<tr>
						<td>
							微博名称
						</td>
						<td>
							<s:textfield name="enterMiscroBoDto.varWeiboName"
								id="varWeiboName" cssClass="textbox_border"></s:textfield>
							<span style="color: red">*</span>
						</td>
						<td>
							微博类型
						</td>
						<td>
						<s:radio list="weiBoType" listKey="key" listValue="value" name="enterMiscroBoDto.intWeiboType" cssClass="textbox_border"></s:radio>							
						</td>
					</tr>
					<tr>
						<td>
							APPKEY
						</td>
						<td>
							<s:textfield name="enterMiscroBoDto.appkey" id="appkey" cssClass="textbox_border"></s:textfield>
						</td>

						<td>
							APPSECRETKEY
						</td>
						<td>
							<s:textfield name="enterMiscroBoDto.appsecretkey"
								id="appsecretkey" cssClass="textbox_border"></s:textfield>
						</td>
					</tr>
					<tr>
						<td>
							CALLBACKURL
						</td>
						<td>
							<s:textfield name="enterMiscroBoDto.callbackurl" id="callbackurl" cssClass="textbox_border"></s:textfield>

						</td>
					</tr>

				</table>
				
			</form>
		</div>

	</body>
</html>
